package com.itheima.day11.propertiesIO.test1;

import java.util.Map;
import java.util.Properties;
import java.util.Set;

public class Test {
    public static void main(String[] args) {
        // 创建properties对象
        Properties prop = new Properties();

        // 增
        prop.put("歌神","张学友");
        prop.put("歌王","陈奕迅");
        prop.put("歌霸","张小凡");
        prop.put("歌屎","糖果超甜");
        System.out.println(prop);

        // 删
        prop.remove("歌屎");
        System.out.println(prop);

        // 改
        prop.put("歌神","张凡");
        System.out.println(prop);

        // 查
        Object o = prop.get("歌神");
        System.out.println(o);

        // 遍历查询
        // 1
        Set<Object> keys = prop.keySet();
        for (Object key : keys) {
            Object value = prop.get(key);
            System.out.println(key + " == " + value);
        }

        System.out.println("======================");

        // 2
        Set<Map.Entry<Object,Object>> entries = prop.entrySet();
        for (Map.Entry<Object, Object> entry : entries) {
            Object key = entry.getKey();
            Object value = entry.getValue();
            System.out.println(key + " == " + value);
        }
    }
}
